package com.heima.search.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.search.service.HistorySearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author Lijx
 * @Date 2024-07-30 14:29
 */
@RestController
@RequestMapping("/api/v1/history")
@Slf4j
public class HistorySearchController {

    @Autowired
    private HistorySearchService historySearchService;

    /**
     * 加载搜索记录列表
     * @return
     */
    @PostMapping("/load")
    public ResponseResult historyWordsSearch(){
        log.info("加载搜索记录列表接口");
        return historySearchService.searchWords();
    }

    /**
     * 删除搜索记录
     * @param params
     * @return
     */
    @PostMapping("/del")
    public ResponseResult deleteHistoryWords(@RequestBody Map<String,String> params ){
        log.info("删除搜索记录接口，入参={}",params);
        String id = params.get("id");
        return historySearchService.deleteHistoryWords(id);
    }
}
